﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YasharEl.Infrastructure.ApplicationModel.Bootstrap.Extensibility;
using YasharEl.Infrastructure.ApplicationModel.Bootstrap.Syntax;
using YasharEl.Infrastructure.ApplicationModel.Bootstrap.Configuration;
using YasharEl.Infrastructure.ApplicationModel.Bootstrap.Behavior;

namespace YasharEl.Infrastructure.ApplicationModel.Bootstrap
{
    public class ComplexBootstrappingStrategy : AbstractBootstrappingStrategy<IComplexBootstrappingExtension>
    {
        protected override void DefineRunSyntax(ISyntaxBuilder<IComplexBootstrappingExtension> builder)
        {
            builder
                .Execute(e => e.Start())
                .Execute(e => e.Ready());
        }

        protected override void DefineShutdownSyntax(ISyntaxBuilder<IComplexBootstrappingExtension> builder)
        {
            builder
                .Execute(e => e.Shutdown())
                .End
                    .With(new DisposeExtensionBehavior());
        }

        protected override void DefineConfigureSyntax(ISyntaxBuilder<IComplexBootstrappingExtension> builder)
        {
            builder
                .Begin
                    .With(new ConfigurationSectionBehavior())
                .Execute(e => e.Configure());
        }
    }
}
